define(['app'],function (app) {
    app.controller('friendCtrl', ['$scope', function($scope,$http) {
      $scope.light = function ($event){
        var x = $event.target;
        angular.element(x).addClass('red');
      };
      function ReadCookie(cookieName) {
        var theCookie = "" + document.cookie;
        var ind = theCookie.indexOf(cookieName);
        if(ind==-1 || cookieName=="") return "";
        var ind1 = theCookie.indexOf(';',ind);
        if(ind1==-1) ind1 = theCookie.length;
        /*读取Cookie值*/
        return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
      }

      function $(id) {
        return document.getElementById(id);
      }

      function init() {
        var content = ReadCookie("content");
        var newtext = '          <div class="person_share">'+
          '<ion-item class="item-remove-animate item-avatar item-icon-right item item-complex" type="item-text-wrap" href="#/tab/post">'+
          '<a class="item-content" ng-href="#/tab/post" href="#/tab/post">'+
          '<img ng-src="img/mike.png" src="img/perry.png">'+
          '<h2>Zauberber</h2>'+
          '<p>'+content+'</p>'+
        '</a>'+
        '</ion-item>'+
        '<div class="comment">'+
          '<a class="icon ion-chatbubble-working comment_a" href="#/tab/post"></a>'+
          '<a class="icon ion-heart comment_a"  href="" ng-click="light($event)"></a>'+
          '</div>';
        if(content && content.length>0) {
          angular.element(community).children().append(newtext);
        } else {
          return false
        }
      }
      window.onload = init();

      $scope.reload = function() {
        window.location.reload();
      }
    }]);
});

